<template>
  <el-dialog
    width="30%"
    title="更换入住套餐"
    :visible.sync="innerVisible"
    append-to-body
    destroy-on-close

  >

    <el-form ref="list"    :model="list"  :rules="rules"  label="top">
      <el-form-item label="套餐名称" prop="name">
        <el-select
          @change="change"
          v-model="value"
          placeholder="请选择套餐"

         >
          <el-option
            v-for="item in options"
            :key="item.mark"
            :label="item.name"
            :value="item.mark">
          </el-option>
        </el-select>

      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="innerVisible = false">取 消</el-button>
      <el-button type="primary" @click="save">保存</el-button>
    </div>
  </el-dialog>
</template>

<script>
    import { searchmnemonicCodeOrName } from "@/api/replacemeal";
    import { replace } from "@/api/replacemeal";
    export default {
        name: "replacemeal",
        data(){
          return{
              list:{
                  packageMark:"",
                  checkInMark:"",
              },
              institutionName:"",
              innerVisible:false,
              loading:false,
              options:[],
              value:"",
              rules: {
                  name: [
                      {required: true, message: '请选择套餐', trigger: 'bulr'},

                  ],
              },

          }
        },
        created(){
            this.institutionName=JSON.parse(localStorage.getItem("institutionName"))
            this.searchmnemonicCodeOrName()
        },
        methods: {
            showEdit(row) {
                console.log(row)
                this.value=""
                console.log(row.checkInMark)
                this.list.checkInMark=row.checkInMark
                this.innerVisible = true;
            },
            searchmnemonicCodeOrName(){
                searchmnemonicCodeOrName(this.institutionName).then(res =>{
                    console.log(res)
                    this.options=res.data.data


                })
            },
            change(data){
                console.log(data)
                this.list.packageMark=data

            },
            save(){
                replace(this.list).then(res =>{
                    console.log(res)
                    if(res.code==200){
                        this.$message({
                            message: "更换成功",
                            type: 'success'
                        })
                    }


                })
              console.log(this.list)

            }
        },


    }
</script>

<style scoped>

</style>
